﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace myFinance.Controls
{
    public partial class AllExpences : UserControl
    {
        public AllExpences()
        {
            InitializeComponent();

            this.dgAllExpences.Focus();

            //for a better dataGrid look
            var expences = new List<object>();
            foreach (var expence in DAL.DALFactory.GetDAL<DAL.SqlCeDAL>().GetAllExpences())
            {
                expences.Add(new
                                {
                                    Desc = expence.Description,
                                    Cat = expence.Category.Name,
                                    Loc = expence.Location.Name,
                                    Date = expence.Date,
                                    Amt = expence.Amount                                                                                                                                                
                                }
                );
            }
            this.dgAllExpences.DataSource = expences;               
        }
    }
}
